package cn.com.connected.common.emnus;


import cn.com.connected.base.exception.BusinessException;
import cn.com.connected.base.exception.ErrorCode;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public enum MsgType {
	t100(1,"被留言","您的动态有人留言了","您的动态有人留言了"),


	;

	private Integer value;
	private String name;
	private String message;
	private String note;


	MsgType(Integer value, String name,String message,String note){
		this.value = value;
		this.name = name;
		this.message = message;
		this.note = note;
	}
	public Integer getValue(){
		return value;
	}
	public String getName(){
		return name;
	}
	public String getNote() {
		return note;
	}

	public String getMessage() {
		return message;
	}

	public static MsgType getByValue(Integer value){
		for (MsgType fileType : MsgType.values()) {
			if (fileType.getValue().intValue() == value.intValue()){
				return fileType;
			}
		}
		throw new BusinessException(ErrorCode.SERIOUS_REQUEST);
	}

	public static List<Map> toMap(){
		return Arrays.stream(MsgType.values()).map(o->new HashMap(){{put("name",o.getName());put("value",o.getValue());put("note",o.getNote());}}).collect(Collectors.toList());
	}
}
